<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 函数无法进行拷贝
        // 正则无法拷呗
        // undefined无法拷贝

        //优点： 二级一下也可以实现深拷贝

        let obj1 = {
            a: 1,
            say() {
                console.log(1)
            },
            person: {
                name: 'zhangsan'
            }
        }

        let obj2 = JSON.parse(JSON.stringify(obj1));
        obj1.a = 2;
        obj1.person.name = 'yyg'
        console.log(obj1)
        console.log(obj2)

    </script>

</body>

</html>